﻿-------------------------------------------------------------------------------
-- This view is the only 2012 specific item in the project
-------------------------------------------------------------------------------
CREATE VIEW dbo.ChangeActivity AS
SELECT
    D.*
FROM
(
    SELECT
        ES.*
    ,   lead(ES.Reputation, 1, NULL) OVER (PARTITION BY ES.EntityID ORDER BY ES.SnapshotTS) - ES.Reputation AS ReputationChange
    FROM
        dbo.EntitySnapshot AS ES
) AS D
WHERE 
    D.ReputationChange <> 0;
